package com.java.system.common.util;

import javafx.scene.control.Cell;
/*import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;*/
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;
import java.text.DecimalFormat;

/**
 * @ClassName: FileUtil
 * @Description:
 * @Version: v1.0.0
 * @Author: Shan Feiyang
 * @Date: 2019/10/8 10:14
 * Modification History:
 * Date           Author           Version     Description
 * -------------------------------------------------------------
 * 2019/10/8      Shan Feiyang        v1.0.0         创建
 */
public class FileUtil {
    /**
     * @param cell description
     * @return java.lang.String
     * @Description 根据数据类型获取数据值
     * @author Shanfeiyang on 2019/10/8 10:17
     **/
    public static String getCellValue(Cell cell) {
        String cellValue = "";
        DecimalFormat df = new DecimalFormat("#");
        if (!StringUtils.isEmpty(cell)) {
            /*switch (cell.getCellType()) {
               *//* case HSSFCell.CELL_TYPE_STRING:
                    cellValue = cell.getRichStringCellValue().getString().trim();
                    break;
                case HSSFCell.CELL_TYPE_NUMERIC:
                    cellValue = df.format(cell.getNumericCellValue()).toString();
                    break;
                case HSSFCell.CELL_TYPE_BOOLEAN:
                    cellValue = String.valueOf(cell.getBooleanCellValue()).trim();
                    break;
                case HSSFCell.CELL_TYPE_FORMULA:
                    cellValue = cell.getCellFormula();
                    break;
                default:
                    cellValue = "";*//*
            }*/
        }
        return cellValue;
    }


    /*public static Workbook getWorkbook(MultipartFile file) throws IOException {
        //解析excel
        //读取文件名
       // Workbook wb = null;
        String filename = file.getOriginalFilename();
        InputStream fis = file.getInputStream();
        if (filename.endsWith("xls")) {
            wb = new HSSFWorkbook(fis);
        } else if (filename.endsWith("xlsx")) {
            wb = new XSSFWorkbook(fis);
        } else {
            return null;
        }
        return wb;
    }*/
}
